#include "Tool.h"

int GetRandNumber(int max)
{
    return rand() % max;
}

void InitBoard(char (*p)[Map_Size])
{
    for (int i = 0; i < Map_Size; i++)
    {
        for (int j = 0; j < Map_Size; j++)
        {
            p[i][j] = '-';
        }
    }
}

void PrintMap(char (*p)[Map_Size], struct Player *player)
{
    InitBoard(p);

    p[player->y][player->x] = 'X';

    printf("    ");
    for (int i = 0; i < Map_Size; i++)
    {
        printf(" %5d", i + 1);
    }
    printf("\n");
    for (int i = 0; i < Map_Size; i++)
    {
        printf("%4d", i + 1);
        for (int j = 0; j < Map_Size; j++)
        {
            printf("  %4c", p[j][i]);
        }
        printf(" \n");
    }
}

struct LuckyWheel *GetRandomLWheel(struct DynamicArray *array)
{
    // 从数组中随机选择一个宝物
    int index = rand() % array->len;
    printf("抽到了%d号奖品\n",index);
    return (struct LuckyWheel*)array->dp[index];
}